package cate.common.table.fight.scene.row;


import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cate.common.table.d.GDFight;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

@NoteClass("战斗场景配置")
@Data
public class FightSceneRow extends ERow {

    @NoteField("功能ID")
    public int funcId;

    @NoteField("最大回合数")
    public int roundMax;

    @NoteField("录像保存天数")
    public int replaySaveDay;

    @NoteField("是否为PVP")
    public boolean isPvP;

    @NoteField("胜负规则")
    public byte winnerRule;

    @NoteField("A方附加技能")
    private String skillAppendACode;

    @NoteField("B方附加技能")
    private String skillAppendBCode;


    @Override
    public void parse(XSSFRowWrap xr) {
        this.id = xr.getInteger("功能ID", 0);
        this.funcId = xr.getInteger("功能ID", 0);
        this.roundMax = xr.getInteger("最大回合数", 15);
        this.replaySaveDay = xr.getInteger("录像保存天数", 0);
        this.isPvP = xr.getBoolean("是否为PVP", false);
        this.winnerRule = xr.getByte("胜负规则", GDFight.WinnerRule.NONE);

        this.skillAppendACode = xr.getString("A方附加技能");
        this.skillAppendBCode = xr.getString("B方附加技能");
    }


    public List<Integer> skillAppendA;

    public List<Integer> skillAppendB;

    @Override
    public void decode() {
        if (StringUtils.isNotBlank(skillAppendACode)) {
            skillAppendA = Str.strArr2intList(skillAppendACode.split("#"));
        }

        if (StringUtils.isNotBlank(skillAppendBCode)) {
            skillAppendB = Str.strArr2intList(skillAppendBCode.split("#"));
        }
    }
}
